package com.thomas.collection;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

/**   
* @Description: TODO(用一句话描述该文件做什么) 
* @author thomas_liu  
* @date 2018年5月13日 下午9:18:07 
* @version V1.0   
*/
public class LinkedListTest {
	
	public static void main(String[] args) {
		List<String> a = new LinkedList<String>();
		a.add("Amy");
		a.add("Carl");
		a.add("Erica");
		
		List<String> b = new LinkedList<String>();
		b.add("Bob");
		b.add("Doug");
		b.add("Frances");
		b.add("Gloria");
		
		
		//merge the words from b into a
		ListIterator<String> aIter = a.listIterator();
		Iterator<String> bIter = b.iterator();
		
		while(bIter.hasNext()){
			if(aIter.hasNext())
				aIter.next();
			aIter.add(bIter.next());
		}
		
		System.out.println(a);
		
		//remove every second word from b
		bIter = b.iterator();
		while(bIter.hasNext()){
			bIter.next();// skip one element
			if(bIter.hasNext()){
				bIter.next();//skip next element
				bIter.remove();// remove that element
			}
		}
		
		System.out.println(b);
		
		//bluk operation remove all words in b from a
		
		a.remove(b);
		
		System.out.println(a);
		
		
		
	}
	
	
	

}
